/**
 * Program  : LogoutDialog.java
 * Author   : long
 * Create   : 2015��10��13�� ����5:29:01
 *
 * Copyright 2015 by Embedded Internet Solutions Inc.,
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Embedded Internet Solutions Inc.("Confidential Information").  
 * You shall not disclose such Confidential Information and shall 
 * use it only in accordance with the terms of the license agreement 
 * you entered into with Embedded Internet Solutions Inc.
 *
 */
	
package cn.broadin.app.hotel.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import cn.broadin.app.hotel.R;

public class UpdateDialog extends Dialog{
	
	private ImageView cancelImageView;
	private ImageView okImageView;
	
	private View.OnClickListener mClickListener;
	
	public UpdateDialog(Context context) {
		super(context, R.style.dialog_loading);
		
		View view = LayoutInflater.from(context).inflate(R.layout.dialog_update, null);
		
		cancelImageView = (ImageView) view.findViewById(R.id.cancel);
		okImageView = (ImageView) view.findViewById(R.id.ok);
		
		
		setContentView(view);
		this.getWindow().setWindowAnimations(R.style.dialogWindowAnim);
		cancelImageView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
			@Override
			public void onFocusChange(View v, boolean hasFocus) {
				if(hasFocus){
					((ImageView)v).setImageResource(R.drawable.btn_cancel1);
				} else {
					((ImageView)v).setImageResource(R.drawable.btn_cancel0);
				}
			}
		});
		cancelImageView.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
		okImageView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
			@Override
			public void onFocusChange(View v, boolean hasFocus) {
				if(hasFocus){
					((ImageView)v).setImageResource(R.drawable.dialog_ok_focus);
				} else {
					((ImageView)v).setImageResource(R.drawable.dialog_ok);
				}
			}
		});
		okImageView.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if(mClickListener == null){
					dismiss();
				} else {
					mClickListener.onClick(v);
					dismiss();
				}
			}
		});
		okImageView.requestFocus();
	}

	public void setClickListener(View.OnClickListener mClickListener) {
		this.mClickListener = mClickListener;
	}
	
	
}
